package com.atguigu.cloud.resp;


import lombok.Getter;

import java.util.Arrays;

@Getter
public enum TestEnum {

    //1.举值
    TSP("1","春天"),
    TSU("5","夏天"),
    TAU("9","秋天"),
    TWI("12","冬天");


    //2.构造
    private final String Month;
    private final String messages;

    TestEnum(String month, String messages) {
        Month = month;
        this.messages = messages;
    }

    //3.遍历
    private static TestEnum  getTestEnum(String month){
        for (TestEnum element : TestEnum.values()) {
            if (element.getMonth().equalsIgnoreCase(month)){
                return element;
            }
        }
        return null;


    }
    //流式计算遍历
    private static TestEnum getTestEnum2(String month){
        return Arrays.stream(TestEnum.values()).filter(x -> x.getMonth().equalsIgnoreCase(month)).findFirst().orElse(null);

    }

    public static void main(String[] args) {
        System.out.println(getTestEnum("1").getMessages());
        System.out.println(getTestEnum2("12").getMessages());
    }
}
